Conversation
Add RTK support for OpenCode alongside existing Claude Code integration. OpenCode users can now install RTK via its native plugin system for transparent command rewriting and token optimization. New files: - hooks/opencode-rtk-plugin.ts: TypeScript plugin that ports the bash rewrite logic to OpenCode's tool.execute.before hook - hooks/opencode-rtk-awareness.md: Slim awareness doc for OpenCode - hooks/opencode-rtk-rules.md: Rules file for OpenCode's rules system CLI changes: - rtk init --opencode [-g]: Install plugin + rules for OpenCode - rtk init --opencode --show: Show OpenCode RTK configuration - rtk init --opencode --uninstall [-g]: Remove OpenCode RTK artifacts - rtk discover --opencode: Scan OpenCode sessions for missed savings Implementation: - OpenCode plugin uses tool.execute.before event to intercept and rewrite bash commands (same patterns as rtk-rewrite.sh) - OpenCodeProvider in discover module supports session scanning - All 418 tests pass, no new clippy errors
Feature/opencode integration
|
Great work on this, thanks for the effort! The Rust code is clean, 418 tests pass, and all existing commands work fine. We have one architectural concern we'd like to discuss before merging. The TypeScript plugin reimplements rewrite logic that should live in Rust. hooks/opencode-rtk-plugin.ts is 309 lines of regex-based command rewriting — the same logic that exists in hooks/rtk-rewrite.sh (bash) and will soon be native Rust via PR #150 (rtk Proposed architecture: rtk hook-rewrite as universal entry point Once PR #150 merges, every integration should call the same Rust binary: Claude Code → hook (JSON) → rtk hook-rewrite OpenCode's tool.execute.before hook https://opencode.ai/docs/plugins/, so the plugin could be ~10 lines: Single source of truth in Rust, zero divergence, trivial to add new providers. Other notes:
Suggestion: Wait for PR #150 to merge, then resubmit with a minimal plugin calling rtk hook-rewrite. We're open to discussing the approach — happy to help shape this! |
Add support for opencode's plugin layout.